﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace MetaSharp.Transformation.Patterns
{
    public class AnyPattern : Pattern
    {
        public AnyPattern()
            : base(PatternKind.Any)
        { }

        public override PatternMatch Compile()
        {
            return Target;
        }

        private static async Task<IMatch> Target(IScope scope)
        {
            if (!scope.Stream.IsEmpty)
            {
                var next = scope.Stream.Next();
                return new Match(
                    next.Current,
                    scope,
                    scope.SetStream(next));
            }

            return await Transformation.Match.Fail(scope);
        }
    }
}
